package ggcache

import "time"

type Option func(g *GgCache)
type SourceFunc func() (interface{}, bool, error)

// WithMod return mod option
func WithMod(mod uint32) Option {
	return func(g *GgCache) {
		if mod > MAX_MOD {
			g.mod = MAX_MOD
		} else if mod < MIN_MOD {
			g.mod = MIN_MOD
		} else {
			g.mod = mod
		}
	}
}

// WithGcInterval return gc interval option
func WithGcInterval(d time.Duration) Option {
	return func(g *GgCache) {
		g.gcInterval = d
	}
}
